package nc.ui.arap.workflow;

import nc.ui.pub.beans.UIPanel;
import nc.vo.arap.engine.ConfigVO;
import nc.vo.arap.workflow.util.IdGeneratorUtil;

public class ConfigDialogFactory {

	public static ConfigDialog getConfigDialog(ConfigVO config,UIPanel owner) {
		ConfigDialog dialog = null;

		String type = config.getType();
		String namespace = config.getNamespace();

		if (type.equals(ConfigVO.SERVICE)) {
			dialog = new ServiceDialog(owner);
		} else if (type.equals(ConfigVO.LISTENER)) {
			dialog = new ListenerDialog(owner);
		} else if (type.equals(ConfigVO.BUTTON)) {
			if (namespace != null && namespace.indexOf(IdGeneratorUtil.SPLIT) != -1) {
				dialog = new ButtonDialog(owner);
			} else {
				dialog = new NamespaceDialog(owner);
			}
		} else if (type.equals(ConfigVO.ACTION)) {
			if (namespace != null && namespace.length()!=0) {
				dialog = new ActionDialog(owner);
			} else {
				dialog = new NamespaceDialog(owner);
			}
		} else if (type.equals(ConfigVO.FLOW)) {
			if (namespace != null && namespace.length()!=0) {
				dialog = new FlowDialog(owner);
			} else {
				dialog = new NamespaceDialog(owner);
			}
		}
		return dialog;
	}
}
